package com.example.rwq_test.threadLocal.integer;

import com.example.rwq_test.threadLocal.MyThreadLocalUtil;

import java.util.concurrent.TimeUnit;

/**
 * TODO note
 *
 * @author renweiqiang
 * @version 1.0.0
 * @createTime 2024/4/15
 */
public class MyIntegerTask implements Runnable {
    private Integer tsakId;

    public MyIntegerTask(Integer tsakId) {
        this.tsakId = tsakId;
    }

    public Integer getTsakId() {
        return tsakId;
    }

    @Override
    public void run() {
        // 任务逻辑
        System.out.println("Task " + this.tsakId +
                " executed by thread: " + Thread.currentThread().getName()
                + ", integerThreadLocal: " + MyThreadLocalUtil.getIntegerThreadLocal().get());
        try {
            TimeUnit.MILLISECONDS.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("handle task finish. taskId: " + this.tsakId);
    }
}
